package com.cloudkinto.controller.stock;


import com.cloudkinto.common.annotations.UserSessionRequired;
import com.cloudkinto.service.stock.vo.pickuprule.PickupRuleReq;
import com.cloudkinto.service.stock.vo.pickuprule.PickupRuleRes;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.cloudkinto.service.stock.StockPickUpRuleService;

import com.cloudkinto.common.web.PageResult;
import com.cloudkinto.common.web.SingleResult;

import javax.servlet.http.HttpServletRequest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.validation.annotation.Validated;

import java.util.HashMap;
import java.util.Map;

import com.cloudkinto.base.BaseController;

/**
 * <p>
 *  前端控制器
 * </p>
 * @author hua
 * @since 2023-04-23
 */
@RestController
@Api(tags = "波次规则模块")
@RequestMapping("/api/admin/StockPickUpRule")
public class StockPickUpRuleController extends BaseController {
    private final Logger logger = LoggerFactory.getLogger(StockPickUpRuleController.class);

    @Autowired
    private StockPickUpRuleService service;

//    @GetMapping("/addInit")
//    @ApiOperation(value = "新增初始化", notes = "新增初始化")
//    public SingleResult addInit() {
//        return service.addInit();
//    }

    @UserSessionRequired
    @PostMapping("")
    @ApiOperation(value = "新增", notes = "新增")
    public SingleResult add(@RequestBody @Validated PickupRuleReq req) {
        Long userId = getCurrentUserId();
        return SingleResult.success("操作成功", service.add(req,userId));
    }

    @UserSessionRequired
    @GetMapping("/updateInit")
    @ApiOperation(value = "编辑初始化", notes = "编辑初始化")
    @ApiImplicitParams({@ApiImplicitParam(name = "storageId", value = "仓库id")})
    @ApiResponses(@ApiResponse(code = 200, message = "", response = PickupRuleRes.class))
    public SingleResult updateInit(Long storageId) {
        return service.updateInit(storageId);
    }

//    @PutMapping("")
//    @ApiOperation(value = "修改", notes = "修改")
//    public SingleResult update(@RequestBody @Validated Object req) {
//        Long userId = getCurrentUserId();
//        return SingleResult.success("修改成功",service.update(req,userId));
//    }
//
//    @DeleteMapping("/{id}")
//    @ApiOperation(value = "根据id删除", notes = "根据id删除")
//    public SingleResult delete(@PathVariable("id") Long id) {
//        Long userId = getCurrentUserId();
//        return SingleResult.success("删除成功",service.delete(id,userId));
//    }
//
//    @GetMapping("/{id}")
//    @ApiOperation(value = "根据id查看详情", notes = "根据id查看详情")
//    public SingleResult detail(@PathVariable("id") Long id) {
//        return SingleResult.success("查询成功",service.detail(id));
//    }
//
//    @GetMapping("/pageInit")
//    @ApiOperation(value = "查询初始化", notes = "查询初始化")
//    public SingleResult pageInit() {
//        return service.pageInit();
//    }
//
//    @GetMapping("/list")
//    @ApiOperation(value = "查询", notes = "查询")
//    public SingleResult list(HttpServletRequest request){
//        Long companyId = getCompanyId();
//
//        Map<String, String> map = new HashMap<>();
//        String keyword = request.getParameter("keyword");
//        map.put("keyword", keyword);
//        return SingleResult.success("查询成功", service.getList(map));
//    }
//
//    @GetMapping("/listPage")
//    @ApiOperation(value = "查询（分页）", notes = "查询（分页）")
//    public PageResult listPage(HttpServletRequest request){
//        Long companyId = getCompanyId();
//
//        Map<String, String> map = new HashMap<>();
//        String keyword = request.getParameter("keyword");
//        String current = request.getParameter("current");
//        String size = request.getParameter("pageSize");
//        map.put("keyword", keyword);
//        map.put("current", current);
//        map.put("pageSize", size);
//        return service.getListPage(map);
//    }

}

